import requests
import xlrd


class Picture(object):
    @staticmethod
    def download(file_url, file_name, file_type):
        response = requests.get(file_url)
        img = response.content
        with open('picture/' + file_name + '.' + file_type, 'wb') as f:
            f.write(img)


def read_excel():
    data = xlrd.open_workbook('data.xls')
    table = data.sheet_by_index(0)
    for i in range(table.ncols, table.nrows):
        file_url = table.row_values(i)[0]
        file_name = str(i)
        file_type = file_url.split('.')[-1]
        print(file_url, file_name, file_type)
        Picture.download(file_url, file_name, file_type)


read_excel()
